﻿<%@ Page Title="Manage Articles" Language="C#" MasterPageFile="~/Web/Site.Master" AutoEventWireup="true" CodeBehind="ManageArticle.aspx.cs" Inherits="pwblog.Web.Admin.ManageArticle" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <h1>Quản lý bài viết</h1>
   <hr />
   <p><i>Hiện toàn bộ bài viết</i></p>
    <asp:GridView ID="gvArticles" runat="server" CellPadding="4" ForeColor="#333333" 
        GridLines="None"
        OnRowEditing="gvArticles_RowEditing"
        OnRowDeleting="gvArticles_RowDeleting"
        OnRowUpdating="gvArticles_RowUpdating"
        OnRowCancelingEdit="gvArticles_RowCancelingEdit"
        OnRowDataBound="gvArticles_RowDataBound" AutoGenerateColumns="False"
        DataKeyNames="Id,IdCategory,UserName,DatePost"
        Width="760px"
        AllowPaging="true"
        PageSize="5"
        onpageindexchanging="gvArticles_PageIndexChanging"
        >
        <Columns>
            
            <asp:TemplateField HeaderText="Title" HeaderStyle-HorizontalAlign="Left" ControlStyle-Width="90px">
                <EditItemTemplate>
                    <asp:TextBox ID="txtNameArticle" runat="server" Text='<%# Bind("Name") %>'
                        Width="90px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvName" ValidationGroup="Update" runat="server"
                        ControlToValidate="txtNameArticle" ErrorMessage="Please Enter Name" 
                        ToolTip="Please Enter Name"
                        SetFocusOnError="true" ForeColor="Red">*</asp:RequiredFieldValidator>
                </EditItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtNameArticle" runat="server" Width="90px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvName" ValidationGroup="Insert" runat="server"
                        ControlToValidate="txtNameArticle" ErrorMessage="Please Enter Name" 
                        ToolTip="Please Enter Name"
                        SetFocusOnError="true" ForeColor="Red">*</asp:RequiredFieldValidator>
                </FooterTemplate>
                <ItemTemplate>
                    <a href="/Web/DetailsArticle.aspx?id=<%# Eval("Id") %>"><%# Eval("Name") %></a>
                </ItemTemplate>

<ControlStyle Width="90px"></ControlStyle>

<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
            </asp:TemplateField>

            
            <asp:TemplateField HeaderText="UserName" HeaderStyle-HorizontalAlign="Left">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlUserName" runat="server" >
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <%# Eval("UserName")%>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:DropDownList ID="ddlUserName" runat="server" >
                    </asp:DropDownList>
                </FooterTemplate>

<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                <ItemStyle Width="100px" />
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Category" HeaderStyle-HorizontalAlign="Left">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlCategory" runat="server" DataTextField="Text" DataValueField="Value"> 
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <%# Eval("Category.Name")%>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:DropDownList ID="ddlCategory" runat="server" DataTextField="Text" DataValueField="Value">
                    </asp:DropDownList>
                </FooterTemplate>

<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                <ItemStyle Width="100px" />
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Edit" ShowHeader="False" HeaderStyle-HorizontalAlign="Left">
                <EditItemTemplate>
                    <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Cập nhật" OnClientClick="return confirm('Update?')"
                        ValidationGroup="Update"></asp:LinkButton>
                    <asp:ValidationSummary ID="vsUpdate" runat="server" ShowMessageBox="true" ShowSummary="false"
                        ValidationGroup="Update" Enabled="true" HeaderText="Validation Summary..." />
                    <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Hủy"></asp:LinkButton>
                </EditItemTemplate>
               
                <ItemTemplate>
                    <asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Sửa" CssClass="button"></asp:LinkButton>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Left" />
                <ItemStyle Width="50px" />
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Edit Article" ShowHeader="False" HeaderStyle-HorizontalAlign="Left">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkEditArticle" runat="server" Text="Sửa bài viết" 
                        CommandArgument='<%# Eval("Id") %>' CssClass="button"
                        OnCommand="gvArticles_lnkEditArticle_Click" />
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Left" />
                <ItemStyle Width="50px" />
            </asp:TemplateField>
            
            <asp:TemplateField HeaderText="Delete" ShowHeader="False" HeaderStyle-HorizontalAlign="Left">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Xóa" CssClass="button" OnClientClick="return confirm('Delete?')"></asp:LinkButton>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Left" />
                <ItemStyle Width="50px" />
            </asp:TemplateField>

        </Columns>
        

    <PagerSettings FirstPageText="First" LastPageText="Last" NextPageText="Next" 
            PreviousPageText="Previous" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>

    <br /><br /><br /><br /><br /><br />
</asp:Content>
